package web.servlet.request.test;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Iterator;
import java.util.Map;

/**
 * @Author Administrator
 * @Date 2020/5/15 10:08
 **/
@WebServlet("/postServlet")
public class PostServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String requestURI = req.getRequestURI();
        System.out.println(requestURI);
        Map<String, String[]> parameterMap = req.getParameterMap();
        Iterator<String> iterator = parameterMap.keySet().iterator();
        while(iterator.hasNext()){
            String key = iterator.next();
            String[] value = parameterMap.get(key);
            for (String s:
                 value) {
                System.out.println(s);
            }
        }
    }
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doGet(req, resp);
    }
}
